package o;

import android.os.Parcel;

public final class cqf {

    static class a extends RuntimeException {
        a(String str, Parcel parcel) {
            super(str);
        }
    }

    static class d extends RuntimeException {
        d(String str) {
            super(str);
        }
    }

    public static int ˋ(Parcel parcel, int i) {
        if ((i & -65536) != -65536) {
            return (i >> 16) & 65535;
        }
        return parcel.readInt();
    }

    public static void ˎ(Parcel parcel, int i, int i2) {
        int ˋ = ˋ(parcel, i);
        if (ˋ != i2) {
            throw new a("Expected size " + i2 + " got " + ˋ + " (0x" + Integer.toHexString(ˋ) + ")", parcel);
        }
    }

    static int ˏ(int i) {
        return 65535 & i;
    }

    static int ˋ(Parcel parcel) {
        int readInt = parcel.readInt();
        int ˋ = ˋ(parcel, readInt);
        int dataPosition = parcel.dataPosition();
        if (ˏ(readInt) != 20293) {
            throw new a("Expected object header. Got 0x" + Integer.toHexString(readInt), parcel);
        }
        readInt = dataPosition + ˋ;
        if (readInt >= dataPosition && readInt <= parcel.dataSize()) {
            return readInt;
        }
        throw new a("Size read is invalid start=" + dataPosition + " end=" + readInt, parcel);
    }

    static void ˏ(Parcel parcel, int i) {
        int dataPosition = parcel.dataPosition();
        int ˋ = ˋ(parcel, i);
        int i2 = dataPosition + ˋ;
        if (i2 < dataPosition || i2 > parcel.dataSize()) {
            throw new d("error length:" + dataPosition + "-" + ˋ);
        }
        parcel.setDataPosition(i2);
    }

    static void ॱ(Parcel parcel, int i) {
        if ((i & -65536) == -65536) {
            parcel.setDataPosition(parcel.dataPosition() - 4);
        }
    }
}
